import 'package:flutter/material.dart';

final RouteObserver<PageRoute> routeObserver = RouteObserver();

abstract class HLBaseState<T extends StatefulWidget> extends State<T> with RouteAware {
  @override
  void didChangeDependencies() {
    routeObserver.subscribe(this, ModalRoute.of(context) as PageRoute);
    super.didChangeDependencies();
  }

  @override
  void dispose() {
    routeObserver.unsubscribe(this);
    super.dispose();
  }
}
